//
//  ViewController.swift
//  Swift2048
//
//  Created by LiynXu on 2016/9/27.
//  Copyright © 2016年 LiynXu. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.view.backgroundColor = UIColor.init(colorLiteralRed: 220/255.0, green: 220/255.0, blue: 220/255.0, alpha: 1)
        addStartButton()

    }
}
extension ViewController{
    func addStartButton()  {
        let button = UIButton(type: .Custom)
        button.frame = CGRectMake(0, 0, 100, 35)
        button.center = self.view.center
        button.addTarget(self, action: #selector(ViewController.start), forControlEvents: .TouchUpInside)
        button.setTitle("开始游戏", forState: .Normal)
        button.setTitleColor(UIColor.blueColor(), forState: .Normal)
        self.view.addSubview(button)
        button.layer.cornerRadius = 5
        button.layer.borderWidth = 1
        button.layer.borderColor = UIColor.init(colorLiteralRed: 72/255.0, green: 180/255.0, blue: 242/255.0, alpha: 1).CGColor
        
    }
    func start()  {
        let alertController = UIAlertController(title: nil, message: "是否开始游戏？", preferredStyle: .Alert)
        let action = UIAlertAction(title: "Ready GO！", style: .Default) { (action:UIAlertAction) in
            //分栏控制器的创建，以及视图的跳转
            let mainTabBar = MainTabBarController()
             self.presentViewController(mainTabBar, animated: true, completion: { 
                
             })
            
        }
        alertController.addAction(action)
        
        self.presentViewController(alertController, animated: true, completion: {
           
        })
    }

}



